package com.cosina.game.robodefence.ui.view;

import android.content.Context;
import android.graphics.Canvas;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;

import com.cosina.game.robodefence.core.BattleEngine;
import com.cosina.game.robodefence.ui.drawable.DrawManager;
import com.cosina.game.robodefence.util.FPS;

public class EnemyView extends View{
	public EnemyView(Context context) {
		super(context);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		long timeMark = SystemClock.currentThreadTimeMillis();
		DrawManager.drawObjects(canvas);

		if (BattleEngine.status == BattleEngine.Status.running) {
			for (int i = 0; i < BattleEngine.speedManager.speed; i++) {
				BattleEngine.withTimeGoRoot();
			}
		}

		long usedTime = SystemClock.currentThreadTimeMillis() - timeMark;
		{
			Log.d("cosina1985", usedTime + "usedTime");
		}
		this.postInvalidateDelayed(FPS.flushInternal - usedTime);
	}
}
